Skip to content

perf(cli): stabilize subagent inspection and dispatch portability - #2007

Merged
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/tui-lineage-performance-consistency
Aug 3, 2026
Merged

perf(cli): stabilize subagent inspection and dispatch portability#2007
limityan merged 1 commit into
GCWing:mainfrom
limityan:yanzhn/tui-lineage-performance-consistency

Conversation

@limityan

@limityan limityan commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Keep the existing OpenCode-aligned View subagents entrypoint while moving lineage query/inspection work off the TUI render loop, adding per-session freshness fences and bounded refresh backoff.
  • Make the Runtime the authoritative owner of settled-turn validation, transcript construction, exact-turn cancellation admission, and terminal persistence; the TUI no longer maintains a parallel settlement state machine or text heuristics.
  • Upgrade private shared Runtime IPC to protocol v15 with a dedicated reader, one ordered writer, and supersedable speculative lineage reads so cancellation is not queued behind inspection.
  • Include the confirmed Windows Dispatch portability fixes: inject the existing runner boundary in tests instead of spawning an unsupported detached process, persist non-verbatim checkout paths, and compare Git paths/line endings semantically.

Architecture and behavior

  • Reuses the existing Agent Runtime, CoreSessionOperationsPort, coordinator mutation lease, session persistence, and TUI event projection. No second Runtime, transcript cache, generic request multiplexer, or new user command is introduced.
  • The outer subagent execution task is the sole terminal persistence owner. Descendant cancellation signals its token and lets that owner drain engine/tool work and write one terminal outcome.
  • Cancellation checks the exact active Turn under the session mutation lease. Once admitted, failures are returned as typed OutcomeUnknown rather than implying a safe retry.
  • Runtime inspection accepts bounded settled-Turn preconditions and returns an authoritative transcript only after every required terminal Turn is durable.
  • TUI fallback state remains bounded to 1 MiB / 4096 events and 256 settled-Turn barriers; event freshness is tracked per session.
  • IPC v15 intentionally fails closed against older private daemons through the existing protocol-version handshake.

Performance and consistency evidence

Path Before After / evidence
TUI Runtime I/O Query/inspect could block the event loop for the Runtime timeout Work runs on the Runtime handle; the loop only polls task completion and Escape cancels speculative reads locally
Settlement refresh Fixed 250 ms retries and TUI-owned settlement heuristics One 5 s absolute window with 250/500/1000 ms backoff; Runtime validates exact durable Turns
Lineage membership Full session-metadata scan Parent-chain traversal, O(depth)
Event lookup Linear scan of retained events Per-session index, O(1), while retaining the bounded raw tail
Slow read vs cancellation Cancellation shared the read's sequential connection path A fake 2 s inspection was superseded in about 110-130 ms, 20/20 runs under 300 ms
Full-duplex backpressure Large request/response writes could wait on each other Deterministic 64-byte duplex transport completed 20/20 runs in about 10 ms each
Cancellation persistence fault A state write error could return before all cancellation signals Real failpoint proves engine token, Tool task, and descendant token are cancelled before typed OutcomeUnknown returns
Dispatch Windows coverage Tests reached an unsupported detached runner; persisted paths could contain \\?\ Existing runner boundary is injected in tests and checkout paths use dunce::canonicalize; full CLI/Dispatch suite passes

Non-goals

  • No Relay feature work.
  • No Windows detached Dispatch runner implementation.
  • No generic IPC multiplexing framework, new Runtime/cache, pagination layer, notification center, or invented TUI/slash command.
  • No workflow changes and no Superpowers documents.

Validation

  • cargo test --workspace -j 2 --quiet -- --format terse
  • cargo check --workspace -j 2
  • cargo test -p bitfun-cli -j 2 (653 unit tests plus all CLI integration suites)
  • cargo test -p bitfun-services-integrations --all-features -j 2 (474 unit tests plus contract/doc tests)
  • cargo test -p bitfun-services-integrations --features review-platform repository_root_accepts_nested_and_file_paths -- --nocapture
  • cargo test -p bitfun-agent-runtime-ipc -j 2 (61 tests)
  • cargo test -p bitfun-agent-runtime lineage -j 2
  • cargo test -p bitfun-core lineage -j 2
  • cargo test -p bitfun-core post_admission -j 2 -- --nocapture
  • cargo test -p bitfun-runtime-ports session_lineage_contracts_serialize_provider_neutral_facts -j 2
  • node scripts/check-core-boundaries.mjs
  • Changed Rust files: rustfmt --edition 2021 --check; git diff --check

The local Windows workspace uses 16 logical cores with a small page file; an earlier unconstrained concurrent link run reproduced rustc exits with 0xc0000409 under commit pressure. The final workspace check and unfiltered workspace test use -j 2 to control linker concurrency, not to reduce test coverage. No CI/workflow workaround is included.

Keep TUI lineage reads nonblocking, move settlement validation to the Runtime owner, and make shared IPC reads supersedable and full duplex. Preserve exact cancellation outcomes and fix the confirmed Windows Dispatch test and worktree path portability issues.
@limityan
limityan merged commit 35fe222 into GCWing:main Aug 3, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant